#include <assert.h>
#include <stdio.h>
#include <string.h>

char* my_strstr(const char* haystack, const char* needle) {
    assert(haystack != NULL);
    assert(needle != NULL);
    const char* p = haystack;
    if(*needle == '\0') {
        return (char*)haystack;
    }
    while(*p) {
        const char* p1 = p;
        const char* p2 = needle;
        while((*p1 != '\0') && (*p2 != '\0') && (*p1 == *p2)) {
            p1++;
            p2++;
        }
        if(*p2 == '\0') {
            return (char*)p;
        }
        p++;
    }
    return NULL;
}

int main() {
    char string1[] = "hello world!";
    char string2[] = "wor";
    char* ret = my_strstr(string1, string2);
    if(ret != NULL) {
        printf("%s\n", ret);
    }else {
        printf("not find!");
    }
    return 0;
}